package com.touni.designpattern.chainofresponsibilitypattern;

/**
 * @ClassName : AbstractLogger
 * @Description :
 * @Author : lwq
 * @Date: 2020-11-20 15:24
 */
public abstract class AbstractLogger {
    public static final int LOGGER_DEBUG = 1;
    public static final int LOGGER_INFO = 2;
    public static final int LOGGER_ERROR = 3;

    public int level;

    public AbstractLogger nextChain;

    public void setNextChain(AbstractLogger nextChain){
        this.nextChain = nextChain;
    }


    public void findChain(int level,String message){
        if (this.level >= level){
            write(message);
        }else {
            nextChain.findChain(level,message);
        }

    }

    abstract void write(String message);

}
